package com.itany.corejava.day17;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class TestNetwork {


    public static void main(String[] args) throws UnknownHostException {
        InetAddress address=InetAddress.getLocalHost();
        String ip=address.getHostAddress();

        System.out.println("ip = " + ip);

        String name=address.getHostName();

        System.out.println("name = " + name);

        InetAddress address2=InetAddress.getByName("www.baidu.com");

        System.out.println(address2.getHostAddress());
    }
}
